<?php
namespace app\http;

use think\worker\Server;

class Worker extends Server
{
    protected $socket = 'http://0.0.0.0:2345';

    public function onMessage($connection,$data)
    {
        $connection->send(json_encode($data));
    }

    public function onConnect($connection)
    {
        echo "New connection\n";
    }



    // 当连接断开时触发
    public function onClose($connection)
    {
        echo "Connection closed\n";
    }

}